package com.yootk.action;

import com.yootk.service.IMessageService;
import com.yootk.vo.Message2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/message/*")
public class MessageAction {

    @Autowired
    private IMessageService messageService;

    @RequestMapping("echo")
    public String echo(String msg) {
        return messageService.echo(msg);
    }

    /**
     * 请求数据验证
     */
    @RequestMapping("echo2")
    public Object echo2(@Valid Message2 message) {
        message.setTitle("【ECHO】" + message.getTitle());
        message.setContent("【ECHO】" + message.getContent());
        return message;
    }
}
